<?php

namespace App\Console\Commands;

use Illuminate\Console\Command;
use App\Model\User\User;
use Illuminate\Support\Facades\DB;
use App\Utils\TeacherRechargeUnit;
use App\Model\User\AuthGroup;

class TeacherRecharge extends Command
{
    /**
     * The name and signature of the console command.
     *
     * @var string
     */
    protected $signature = 'test';

    /**
     * The console command description.
     *
     * @var string
     */
    protected $description = '每月自动为教师充值餐补';

    /**
     * Create a new command instance.
     *
     * @return void
     */
    public function __construct()
    {
        parent::__construct();
    }

    /**
     * Execute the console command.
     *
     * @return mixed
     */
    public function handle()
    {
        $users = User::whereHas('groups', function ($query) {
            $query->where('group_id', 1);
        })->select('id')->get();
        foreach ($users as $user){
            TeacherRechargeUnit::recharge(500, $user['id']);
        }

    }
}
